import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '发票号码',
    align: "center",
    dataIndex: 'code'
  },
  {
    title: '用户ID',
    align: "center",
    dataIndex: 'userId'
  },
  {
    title: '订单ID',
    align: "center",
    dataIndex: 'orderId'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '更新日期',
    align: "center",
    dataIndex: 'updateTime'
  },
  {
    title: '发票金额',
    align: "center",
    dataIndex: 'amt'
  },
  {
    title: '预付款',
    align: "center",
    dataIndex: 'preAmt'
  },
  {
    title: '结账日期',
    align: "center",
    dataIndex: 'checkoutTime'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
  {
    title: '开票点',
    align: "center",
    dataIndex: 'billCode_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "状态",
    field: "status",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "valid_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "开票点",
    field: "billCode",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_bill_point,name,code"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '发票号码',
    field: 'code',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入发票号码!' },
      ];
    },
  },
  {
    label: '用户ID',
    field: 'userId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入用户ID!' },
      ];
    },
  },
  {
    label: '订单ID',
    field: 'orderId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入订单ID!' },
      ];
    },
  },
  {
    label: '创建人',
    field: 'createBy',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入创建人!' },
      ];
    },
  },
  {
    label: '创建日期',
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入创建日期!' },
      ];
    },
  },
  {
    label: '更新人',
    field: 'updateBy',
    component: 'Input',
  },
  {
    label: '更新日期',
    field: 'updateTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '发票金额',
    field: 'amt',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入发票金额!' },
      ];
    },
  },
  {
    label: '预付款',
    field: 'preAmt',
    component: 'InputNumber',
  },
  {
    label: '结账日期',
    field: 'checkoutTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "valid_status"
    },
  },
  {
    label: '开票点',
    field: 'billCode',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_bill_point,name,code"
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

//子表列表数据
export const nurseUserBillDetailColumns: BasicColumn[] = [
  {
    title: '发票ID',
    align: "center",
    dataIndex: 'billId'
  },
  {
    title: '商品ID',
    align: "center",
    dataIndex: 'goodsId'
  },
  {
    title: '商品名称',
    align: "center",
    dataIndex: 'goodsName'
  },
  {
    title: '商品价格',
    align: "center",
    dataIndex: 'price'
  },
  {
    title: '数量',
    align: "center",
    dataIndex: 'num'
  },
  {
    title: '总金额',
    align: "center",
    dataIndex: 'amt'
  },
  {
    title: '费用类型',
    align: "center",
    dataIndex: 'costType'
  },
  {
    title: '费用类型名称',
    align: "center",
    dataIndex: 'costTypeName'
  },
  {
    title: '开票代码',
    align: "center",
    dataIndex: 'billCode'
  },
  {
    title: '开票名称',
    align: "center",
    dataIndex: 'billName'
  },
  {
    title: '单位',
    align: "center",
    dataIndex: 'unit'
  },
  {
    title: '规格',
    align: "center",
    dataIndex: 'specs'
  },
  {
    title: '商品上级ID',
    align: "center",
    dataIndex: 'pid'
  },
  {
    title: '商品上级名称',
    align: "center",
    dataIndex: 'pname'
  },
];
//子表表单数据
export const nurseUserBillDetailFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '发票ID',
    field: 'billId',
    component: 'Input',
  },
  {
    label: '商品ID',
    field: 'goodsId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入商品ID!' },
      ];
    },
  },
  {
    label: '商品名称',
    field: 'goodsName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入商品名称!' },
      ];
    },
  },
  {
    label: '商品价格',
    field: 'price',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入商品价格!' },
      ];
    },
  },
  {
    label: '数量',
    field: 'num',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入数量!' },
      ];
    },
  },
  {
    label: '总金额',
    field: 'amt',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入总金额!' },
      ];
    },
  },
  {
    label: '费用类型',
    field: 'costType',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入费用类型!' },
      ];
    },
  },
  {
    label: '费用类型名称',
    field: 'costTypeName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入费用类型名称!' },
      ];
    },
  },
  {
    label: '开票代码',
    field: 'billCode',
    component: 'Input',
  },
  {
    label: '开票名称',
    field: 'billName',
    component: 'Input',
  },
  {
    label: '单位',
    field: 'unit',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入单位!' },
      ];
    },
  },
  {
    label: '规格',
    field: 'specs',
    component: 'Input',
  },
  {
    label: '商品上级ID',
    field: 'pid',
    component: 'Input',
  },
  {
    label: '商品上级名称',
    field: 'pname',
    component: 'Input',
  },
];
//子表列表数据
export const nurseUserBillInvoiceColumns: BasicColumn[] = [
  {
    title: '发票ID',
    align: "center",
    dataIndex: 'billId'
  },
  {
    title: '发票号码',
    align: "center",
    dataIndex: 'code'
  },
  {
    title: '校验码',
    align: "center",
    dataIndex: 'checkCode'
  },
  {
    title: '发票地址',
    align: "center",
    dataIndex: 'url'
  },
  {
    title: '发票图片',
    align: "center",
    dataIndex: 'pic',
    customRender: render.renderImage,
  },
  {
    title: '用户ID',
    align: "center",
    dataIndex: 'userId'
  },
  {
    title: '订单ID',
    align: "center",
    dataIndex: 'orderId'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '更新日期',
    align: "center",
    dataIndex: 'updateTime'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
  {
    title: '类型',
    align: "center",
    dataIndex: 'receiveType'
  },
  {
    title: '发票抬头',
    align: "center",
    dataIndex: 'invoiceHeader'
  },
  {
    title: '税号',
    align: "center",
    dataIndex: 'dutyParagraph'
  },
  {
    title: '接收方式',
    align: "center",
    dataIndex: 'mode'
  },
  {
    title: '总金额',
    align: "center",
    dataIndex: 'totalPrice'
  },
  {
    title: '手机号',
    align: "center",
    dataIndex: 'phone'
  },
  {
    title: '邮箱',
    align: "center",
    dataIndex: 'email'
  },
  {
    title: '扩展',
    align: 'center',
    dataIndex: 'extend'
  },
];


//子表表单数据
export const nurseUserBillInvoiceFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '发票ID',
    field: 'billId',
    component: 'Input',
  },
  {
    label: '发票号码',
    field: 'code',
    component: 'Input',
    // dynamicRules: ({ model, schema }) => {
    //   return [
    //     { required: true, message: '请输入发票号码!' },
    //   ];
    // },
  },
  {
    label: '校验码',
    field: 'checkCode',
    component: 'Input',
    // dynamicRules: ({ model, schema }) => {
    //   return [
    //     { required: true, message: '请输入校验码!' },
    //   ];
    // },
  },
  {
    label: '发票地址',
    field: 'url',
    component: 'Input',
  },
  {
    label: '发票图片',
    field: 'pic',
    component: 'JImageUpload',
    componentProps: {
    },
  },
  {
    label: '用户ID',
    field: 'userId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入用户ID!' },
      ];
    },
  },
  {
    label: '订单ID',
    field: 'orderId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入订单ID!' },
      ];
    },
  },
  {
    label: '创建人',
    field: 'createBy',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入创建人!' },
      ];
    },
  },
  {
    label: '创建日期',
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入创建日期!' },
      ];
    },
  },
  {
    label: '更新人',
    field: 'updateBy',
    component: 'Input',
  },
  {
    label: '更新日期',
    field: 'updateTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "valid_status"
    },
  },
  {
    label: '类型',
    component: 'Input',
    field: 'receiveType'
  },
  {
    label: '发票抬头',
    component: 'Input',
    field: 'invoiceHeader'
  },
  {
    label: '税号',
    component: 'Input',
    field: 'dutyParagraph'
  },
  {
    label: '接收方式',
    component: 'Input',
    field: 'mode'
  },
  {
    label: '总金额',
    component: 'Input',
    field: 'totalPrice'
  },
  {
    label: '手机号',
    component: 'Input',
    field: 'phone'
  },
  {
    label: '邮箱',
    component: 'Input',
    field: 'email'
  },
  {
    label: '扩展',
    component: 'Input',
    field: 'extend'
  },
];

// 高级查询数据
export const superQuerySchema = {
  code: { title: '发票号码', order: 0, view: 'text', type: 'string', },
  userId: { title: '用户ID', order: 1, view: 'text', type: 'string', },
  orderId: { title: '订单ID', order: 2, view: 'text', type: 'string', },
  createBy: { title: '创建人', order: 3, view: 'text', type: 'string', },
  createTime: { title: '创建日期', order: 4, view: 'datetime', type: 'string', },
  updateBy: { title: '更新人', order: 5, view: 'text', type: 'string', },
  updateTime: { title: '更新日期', order: 6, view: 'datetime', type: 'string', },
  amt: { title: '发票金额', order: 7, view: 'number', type: 'number', },
  preAmt: { title: '预付款', order: 8, view: 'number', type: 'number', },
  checkoutTime: { title: '结账日期', order: 9, view: 'datetime', type: 'string', },
  status: { title: '状态', order: 10, view: 'radio', type: 'string', },
  billCode: { title: '开票点', order: 11, view: 'list', type: 'string', dictTable: "nurse_bill_point", dictCode: 'code', dictText: 'name', },
};
